#include<bits/stdc++.h>
using namespace std;
#define A 100005
#define ll long long;
int main(){
    int n=0,t,a[1000000];
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        if(n==8) cout<<8<<" ";
        if(n==4) cout<<0<<" ";
        if(n==3) cout<<1<<" ";
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
